package com.lxw.oa.controller.common;

import com.lxw.oa.controller.io.BaseTo;
import com.lxw.oa.entity.User;
import com.lxw.oa.service.UserService;
import com.lxw.oa.util.LogAopIn;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Controller
@EnableTransactionManagement
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     *
     * @return
     */
    @LogAopIn(moduleName="个人信息",option="获取个人信息")
    @PostMapping("/getInformation")
    @ResponseBody
    public BaseTo getInformation(){
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        String name = user.getName();
        List<HashMap> list = userService.getInformation(name);
        return new BaseTo(list);
    }
}
